package com.han.verifycode.data.area;

import com.han.verifycode.data.Area;
import com.han.verifycode.data.Position;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 圆形范围
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CircleArea extends Area {
    /**
     * 圆心
     */
    private Position core;

    /**
     * 半径
     */
    private int radius;

    public boolean verifyPosition(Position position) {
        double s1 = Math.pow((double) Math.abs(position.getX() - position.getX()), 2);
        double s2 = Math.pow((double) Math.abs(core.getY() - core.getY()), 2);
        double result = Math.sqrt(s1 + s2);
        return result - radius <= 0.0;
    }
}
